package com.restaurant.application.levelset.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class LevelSetPageData implements PickableBean {

    public static final String FN_MEMBERLEVEL = "memberLevel";
    public static final String FN_MEMBERNAME = "memberName";
    public static final String FN_SCORE = "score";
    public static final String FN_SEQ = "seq";
    public static final String FN_SAVEPATH = "savePath";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_MEMBERLEVEL,
            FN_MEMBERNAME,
            FN_SCORE,
            FN_SEQ,
            FN_SAVEPATH);
    
    private Integer memberLevel;
    private String memberName;
    private Integer score;
    private Long seq;
    private String savePath;

    public LevelSetPageData(Integer memberLevel, String memberName, Integer score, Long seq, String savePath) {
        setMemberLevel(memberLevel);
        setMemberName(memberName);
        setScore(score);
        setSeq(seq);
        setSavePath(savePath);
    }

    public LevelSetPageData() {
    }

    public LevelSetPageData duplicate() {
        LevelSetPageData result = new LevelSetPageData();
        result.memberLevel = this.memberLevel;
        result.memberName = this.memberName;
        result.score = this.score;
        result.seq = this.seq;
        result.savePath = this.savePath;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public Integer getMemberLevel() {
        return memberLevel;
    }

    public void setMemberLevel(Integer value) {
        this.memberLevel = value;
    }

    public LevelSetPageData withMemberLevel(Integer value) {
        setMemberLevel(value);
        return this;
    }

    public LevelSetPageData withMemberLevel(Integer value, Integer defaultValue) {
        setMemberLevel(value == null ? defaultValue : value);
        return this;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String value) {
        this.memberName = value;
    }

    public LevelSetPageData withMemberName(String value) {
        setMemberName(value);
        return this;
    }

    public LevelSetPageData withMemberName(String value, String defaultValue) {
        setMemberName(value == null ? defaultValue : value);
        return this;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer value) {
        this.score = value;
    }

    public LevelSetPageData withScore(Integer value) {
        setScore(value);
        return this;
    }

    public LevelSetPageData withScore(Integer value, Integer defaultValue) {
        setScore(value == null ? defaultValue : value);
        return this;
    }

    public Long getSeq() {
        return seq;
    }

    public void setSeq(Long value) {
        this.seq = value;
    }

    public LevelSetPageData withSeq(Long value) {
        setSeq(value);
        return this;
    }

    public LevelSetPageData withSeq(Long value, Long defaultValue) {
        setSeq(value == null ? defaultValue : value);
        return this;
    }

    public String getSavePath() {
        return savePath;
    }

    public void setSavePath(String value) {
        this.savePath = value;
    }

    public LevelSetPageData withSavePath(String value) {
        setSavePath(value);
        return this;
    }

    public LevelSetPageData withSavePath(String value, String defaultValue) {
        setSavePath(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "memberLevel":
                return getMemberLevel();
            case "memberName":
                return getMemberName();
            case "score":
                return getScore();
            case "seq":
                return getSeq();
            case "savePath":
                return getSavePath();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof LevelSetPageData)) return false;
        return signature().equals(((LevelSetPageData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean LevelSetPageData has no signature defined, no hash code or equals possible.");
    }
}
